package com.example.learn.juc.container.map;

import java.util.concurrent.ConcurrentSkipListMap;

/**
 * @author 王明
 * @date 2025/11/10 11:27
 */
public class ConcurrentSkipListMapDemo {
    public static void main(String[] args) {
        ConcurrentSkipListMap<Integer, String> map = new ConcurrentSkipListMap<>();
        // 添加元素
        map.put(1, "a");
        map.put(3, "c");
        map.put(2, "b");
        map.put(4, "d");

        // 获取元素
        String value1 = map.get(2);
        // 输出：b
        System.out.println(value1);
        // 遍历元素
        for (Integer key : map.keySet()) {
            String value = map.get(key);
            System.out.println(key + " : " + value);
        }

        // 删除元素
        String value2 = map.remove(3);
        // 输出：c
        System.out.println(value2);
    }
}
